package com.dstation.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dstation.domain.OrderInfo;
import com.dstation.dao.OrderInfoMapper;
import com.dstation.service.interf.IOrderService;
import com.dstation.utils.OrderStatus;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrderServiceImpl  implements IOrderService {
    @Resource
    private OrderInfoMapper orderMapper;


    @Override
    public IPage<OrderInfo> findMyOrderById(Page ipage, Long userId) {

        return orderMapper.selectMyOrderById(ipage,userId);
    }

    @Override
    public boolean findOrderIsTimeLimit(long orderId) {
        return orderMapper.selectOrderIsTimeLimit(orderId)== OrderStatus.ORDER_TIMELIMIT_STATUS;
    }

    @Override
    public boolean dropOrderById(long orderId) {
        return orderMapper.deleteOrderById(orderId)==1;
    }

    @Override
    public IPage<OrderInfo> findAllOrder(Page page) {
        return orderMapper.selectAllOrder(page);
    }

    @Override
    public IPage<OrderInfo> findOrderById(Page<OrderInfo> orderInfoPage, Integer orderId) {
        return orderMapper.selectOrderById(orderId,orderInfoPage);
    }
}
